<?php
require_once("../../../config.inc.php");
require_once("../../../app/_inc/include.php");

$errMsg = sxREQ('msg');
if(!isset($_REQUEST["menu_line"])){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true)."&msg=".urlencode(_t("variabile 'menu_line' non passata")); 
	serverRedir($url);
}
if (sxREQ('del')=='yes') {
	$errMsg .= menuPageLineDel();
}
$menuLine = sxREQ('menu_line');
$module = substr($menuLine,0,4);
$menuPage = substr($menuLine,5,4);
$sql = "SELECT ml.*, m.description AS mdes, mp.description AS pdes, g.description AS gdes, g.sequence AS gseq " .
		" FROM menu_line ml " .
		" INNER JOIN menu_page mp ON mp.module = ml.module AND mp.menu_page = ml.menu_page ".
		" INNER JOIN module m ON m.module = mp.module ".
		" LEFT JOIN menu_group g ON g.module = mp.module " .
		"    AND g.menu_page = '$menuPage' AND g.menu_group = ml.menu_group ".
		" WHERE ml.menu_line = '$menuLine'";
$objSDAO->query($sql,"forvis");
if(!$row = $objSDAO->fetch("forvis")){
	$url = $_SESSION[USEROBJ]->getHistory(-1, true)."&msg=".urlencode(_t("variabile 'menu_line' non passata")); 
	serverRedir($url);
}
//output HTML
$aOpz = array("tit2"=>_t("Crereqtype nuova voce men@"));
echo(headerHTML($aOpz));
?>
<script language="JavaScript" type="text/javascript">
	function confDelMenuLine(){
		try{
			if (confirm("Confermi la cancellreqtype della voce di men@ ?")) {
				document.location.href = "menuPageLineView.php?<?="del=yes&menu_line=$menuLine&xsn=".XSN?>";
			}
		}catch(e){
			raiseError(e.description, "save new sub-module");
		}			
	}
</script>
  
<?php
echo(bodyHTML($aOpz));
echo("<table width=\"100%\" cellpadding=\"03\" cellspacing=\"0\">\n<tr>\n<td>\n");
//output comandi
$aCmd = array(
					"modml"=>array("pag"=>"menuPageLineMod.php?menu_line=$menuLine",
										"title"=>_t("mofifica voce men@"),
										"text"=>_t("modifica")
										),
					"delml"=>array("pag"=>"javascript:confDelMenuLine();",
										"title"=>_t("conferma eliminreqtype voce men@"),
										"text"=>_t("elimina")
										),
					"back"=>array("pag"=>$objUser->getHistory(-1,false),
										"title"=>$objUser->getHistoryText(-1),
										"text"=>$objUser->getHistoryText(-1)
										)
					);
echo(commandsHTML($aCmd));	
echo("<table class=\"tabl01\" width=\"100%\" cellpadding=\"3\" cellspacing=\"2\" border='0'>\n");
echo("<tr>" .
			"<td class=\"titl01\" width=\"20%\" colspan='4'>"._t("Modulo").": $module - ".$row['mdes'].' - '.
			_t('Pagina men@').': '.$menuPage.' - '.$row['pdes']."</td>" .
		"</tr>\n");
if (trim($row['menu_group'])=='') {
	echo("<tr>" .
				"<td class=\"labl01\" width='15%'>"._t("gruppo voci")."</td>" .
				"<td class=\"text01\" width='45%'>&nbsp;</td>" .
				"<td class=\"labl01\" width='10%'>"._t("sequenza")."</td>" .
				"<td class=\"text01\" width='30%'>&nbsp;</td>" .
			"</tr>\n");	
} else {
	echo("<tr>" .
				"<td class=\"labl01\" width='15%'>"._t("gruppo voci")."</td>" .
				"<td class=\"text01\" width='45%'>" .
				"<a class='text01' href=\"javascript:pageRedir('menuPageGroupView.php?".
				"mod=".$module."&menu_page=".$menuPage."&menu_group=".$row['menu_group']."&xsn=".XSN."');\" >".
				$row['menu_group'].' - '.$row['gdes']."</a></td>" .
				"<td class=\"labl01\" width='10%'>"._t("sequenza")."</td>" .
				"<td class=\"text01\" width='30%'>".$row['gseq']."</td>" .
			"</tr>\n");	
	}
echo("<tr>" .
			"<td class=\"labl01\">"._t("voce")." (*)</td>" .
			"<td class=\"text01\">".substr($row['menu_line'],10).' - '.$row['description']."</td>" .
			"<td class=\"labl01\">"._t("sequenza")."</td>" .
			"<td class=\"text01\">".$row['sequence']."</td>" .
		"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">"._t("pagina menu")."</td>" .
			"<td class=\"text01\" colspan='3'>".$row['linked_page']."</td>" .
		"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">"._t("processo")."</td>" .
			"<td class=\"text01\" colspan='3'>".$row['process_unit']."</td>" .
		"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">"._t("query string")."</td>" .
			"<td class=\"text01\" colspan='3'>".$row['query_string']."</td>" .
			"</tr>\n");
echo("<tr>" .
			"<td class=\"labl01\">"._t("note")."</td>" .
			"<td class=\"text01\" colspan='3'><pre class='text01'>".$row['note']."</pre></td>" .
		"</tr>\n");
echo("</table>");

echo(commandsHTML($aCmd));
echo("<div id=\"messArea\" class=\"mess01\">$errMsg</div>");
echo("</td>\n</tr>\n</table>\n");
echo(footerHTML());

function menuPageLineDel(){
	global $objSDAO;
	$errMsg = "";
	$sSQL = "DELETE FROM menu_line WHERE menu_line = '".sxRAS('menu_line')."'";		
	$objSDAO->query($sSQL,"del");
	logRecord("300", _t("eliminata voce men@ '".sxREQUEST('module').".".sxREQUEST('menu_page').".".sxREQUEST('menu_line')."'"));
	$url = $_SESSION[USEROBJ]->getHistory(-1, true);
	serverRedir($url);
	exit;
}

?>
